// 构造组件

var router1 = Vue.extend({
    template: '<div>路由一内容</div>'
});

var router2 = Vue.extend({
    template: '<div>路由二内容</div>'
});

var router3 = Vue.extend({
    template: '<div>路由三内容</div>'
});
//定义路由
var router = new VueRouter({
    routes: [{
        path: '/route1',
        name: 'route1',
        meta: {
            title: '路由一'
        },
        component: router1
    },
        {
            path: '/route2',
            name: 'route2',
            meta: {
                title: '路由二'
            },
            component: router2
        },
        {
            path: '/route3',
            name: 'route3',
            meta: {
                title: '路由三'
            },
            component: router3
        }
    ]
});

// 定义vue实例
var app = new Vue({
    el: '#app',
    router
})


//全局钩子
router.beforeEach((to, from, next) => {
    console.log(to);
    console.log(from);
    window.document.title =to.meta.title
    // next(false);
    next()
});